package com.chyer.logistics_interest.controller;

import com.chyer.logistics_interest.entity.stock.StockModel;
import com.chyer.logistics_interest.service.StockService;
import com.chyer.logistics_interest.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/stock")
public class StockController {

    @Autowired
    private StockService stockService;

    //根据股票代码查询股票信息
    @GetMapping("/info")
    public R getInfoByCode(@RequestParam("code")String code){
        StockModel stock = stockService.getStockInfoByCode(code);
        return new R(stock);
    }

    //根据股票代码查询股票信息
    @PostMapping("/list/info")
    @ResponseBody
    public R listInfosByCode(@RequestBody List<String> codes){
        List<StockModel> stockList = stockService.listStockInfoByCodes(codes);
        return new R(stockList);
    }



}
